/**
 * 
 * @anther苗宇
 */

 Date.prototype.format = function(format) {  
	        var o = {  
	            "M+": this.getMonth() + 1, // month  
	            "d+": this.getDate(), // day  
	            "h+": this.getHours(), // hour  
	            "m+": this.getMinutes(), // minute  
	            "s+": this.getSeconds(), // second  
	            "q+": Math.floor((this.getMonth() + 3) / 3), // quarter  
	            "S": this.getMilliseconds()  
	            // millisecond  
	        }  
	        if (/(y+)/.test(format))  
	            format = format.replace(RegExp.$1, (this.getFullYear() + "")  
	                .substr(4 - RegExp.$1.length));  
	        for (var k in o)  
	            if (new RegExp("(" + k + ")").test(format))  
	                format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));  
	        return format;  
	    }  
function formatDatebox(value) {  
	    if (value == null || value == '') {  
	        return '';  
	    }  
	    var dt;  
	    if (value instanceof Date) {  
	        dt = value;  
	    } else {  
	        dt = new Date(value);  
	    }  
	  
	    return dt.format("yyyy-MM-dd hh:mm:ss"); //扩展的Date的format方法(上述插件实现)  
	}

function formatOper(val,row,index){
	return '<a href="#" onclick="editTicket('+index+')">修改</a>';//val当前单元格的值,row当前行对象,index当前行索引
}

function editTicket(index){
	$('#dg').datagrid('selectRow',index);
	var row=$('#dg').datagrid('getSelected');//获取选中的行
	if(row){
		$('#dlg').dialog('open').dialog('setTitle','修改票务信息');
		$('#fm').form('load',row);
		url='../adminServlet?param=update&id='+row.id;
	}
	
}



$(function(){$('#pageGrid').datagrid({
        url:'UserController/pageGatagridUser',
        pagination:true,
        columns:[[
            {field:'username',title:'姓名',width:100},
            {field:'sex',title:'性别',width:100},
            {field:'province',title:'省份',width:100},
            {field:'city',title:'城市',width:100},
            {field:'_operate',title:'操作',width:100,formatter:formatOper,align:'right'}
            
        ]]
    });
});

